package randomdata;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;

//�����������
public class FormatData {
	
	static Random random = new Random();
	
	//�������ip
	static String randomip() {
		
		StringBuffer stringBuffer = new StringBuffer();
		for (int i = 0; i < 4; i++) {
			Integer num = 1 + random.nextInt(255);
			stringBuffer.append(num.toString() + ".");
		}
		
		stringBuffer.deleteCharAt(stringBuffer.length() - 1);
		return stringBuffer.toString();
	}
	
	//��������û���	
	static String randomUserName() {
		StringBuffer stringBuffer = new StringBuffer();
		Integer len = ConstSeed.useridseed.length();
		
		for (int i = 0; i < 24; i++) {
			Integer num = random.nextInt(len);
			stringBuffer.append(ConstSeed.useridseed.charAt(num));
		}
		
		return stringBuffer.toString();
	}
	

	//��������¼�
	static String randomtime() {
		long time = 86400;
		time *= 1000*(365*40+10);
		long delta = random.nextInt(86400);
		//last to 2018.05.01
		delta *= 3042*1000;
		Date date = new Date(time+delta);
		SimpleDateFormat ret = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); 
		return ret.format(date).toString();
	}
	
	static String quickGetIp() {
		return ConstSeed.randomIp[random.nextInt(100)];
	}
	
	static String quickGetTime() {
		return ConstSeed.randomTime[random.nextInt(100)];
	}
	
	static String quickGetURL() {
		return ConstSeed.website[random.nextInt(99)];
	}
	
	static String quickGetName() {
		return ConstSeed.randomName[random.nextInt(100)];
	}
	
	//����һ�������ļ�¼
	public static String getARecord() {
		String split = "\t";
		
		String ret = quickGetIp() + split + 
					 quickGetName() + split +
					 quickGetTime() + split +
					 quickGetURL() + split +
					 quickGetURL() + split +
					 "agent" + quickGetName().substring(5) + split +
					 quickGetIp() + split +
					 "cookie" + quickGetName().substring(6);
		return ret;
	}

	public static void main(String[] args) {
		for (int i = 0; i < 100; i++) {
			System.out.println("\"" + getARecord() + "\",");
		}
	}
}
